<?php 
// 链接QQ登录
function qq_login()
{
	Vendor('QQConnect.API.qqConnectAPI');
	$qc = new QC();
	$qc->qq_login();
}
//获取openid
function getOpenid()
{
	Vendor('QQConnect.API.qqConnectAPI');
	$qc = new QC();
	$qc->qq_callback();
    return $qc->get_openid();
}
//获取用户信息
function getUserInfo()
{
	Vendor('QQConnect.API.qqConnectAPI');
	$qc = new QC();
	return $qc->get_user_info();
}
// 图片下载
function getQQFace($url)
{
	//初始化
	$ch = curl_init();
	//设置选项，包括URL
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	//执行并获取HTML文档内容
	$output = curl_exec($ch);
	//释放curl句柄
	curl_close($ch);
	//打印获得的数据
	$path = "Uploads/qq/".uniqid().".jpg";

	file_put_contents($path,$output);

	return $path;
}
//发邮件
function qqemail($email,$title,$str)
{
	Vendor('PHPMailer.PHPMailerAutoload');

	$mail = new PHPMailer;

	//$mail->SMTPDebug = 3;                               // Enable verbose debug output

	$mail->isSMTP();                                      // Set mailer to use SMTP（服务器格式 SMTP）
	$mail->Host = 'smtp.qq.com'; 	// Specify main and backup SMTP servers（SMTP 服务器地址）
	$mail->SMTPAuth = true;                               // Enable SMTP authentication（认证SNTP）
	$mail->Username = '1404451270@qq.com';                 // SMTP username
	$mail->Password = 'aeolrzbyaokpjbjg';                           // SMTP password
	$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
	$mail->Port = 465;                                    // TCP port to connect to

	$mail->setFrom('1404451270@qq.com', 'Mailer');      	  // A发件人
	$mail->addAddress($email, 'Joe User');     // 收件人
	// $mail->addAddress('ellen@example.com');               // Name is optional 第2个收件人
	// $mail->addReplyTo('info@example.com', 'Information');  通知人
	// $mail->addCC('cc@example.com');							抄送人
	// $mail->addBCC('bcc@example.com');

	// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments附件
	// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name 图片
	$mail->isHTML(true);                                  // Set email format to HTML 

	$mail->Subject = $title;
	$mail->Body    = $str;
	// $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

	if(!$mail->send()) {
	    echo 'Message could not be sent.';
	    echo 'Mailer Error: ' . $mail->ErrorInfo;
	} else {
	    return true;
	}
	// location.href = "{:U('home/cen/user')}"
	
}
// 搜索分词
    function seek($text)
    {
    	Vendor('Pscws4.pscws4','','.class.php');
    	$pscws = new PSCWS4('utf8');
    	// 词典
    	$pscws->set_dict('./Public/dict.utf8.xdb');
    	// 人名
		$pscws->set_rule('./ThinkPHP/Library/Vendor/Pscws4/etc/rules.ini');
        $pscws->send_text($text);
        // var_dump(strlen($text));
        
        // var_dump($some);
        if (strlen($text)<6) {
        	$some = $pscws->get_result();
        	return $some;
   //      	while ($some = $pscws->get_result()){
			// 	foreach ($some as $word){
			// 	  $sc[0]= $word;
			// 	  return $sc;
			//     }
			// }
        }
		// 
		$tops=$pscws->get_tops(3,'n,v');
		// var_dump($tops);
		return $tops;
	}



 ?>